<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

/**
 * Description of Autoloader
 *
 * @todo 
 * 
 * @author George Zeakis<zeageorge@google.com>
 * 
 */
class Autoloader {
    
    protected $_paths = NULL;
    
    public function __construct(){ }
    
    public function setPaths(array $paths){
        
        if (!spl_autoload_register(array($this, 'autoloader'))) {
//            throw new Exception('Error::Could not set Autoload function');
            return FALSE;
        }
        
        $this->_paths = $paths;
        return TRUE;
    }

    public function autoloader($class_name){
        if (class_exists($class_name, FALSE)) { return TRUE; }

        if (file_exists($this->_paths.$class_name.'.php')) {
           require_once $this->_paths.$class_name.'.php';
           return TRUE;
        }
        return FALSE;
    }
    
    public function __destruct() {
        spl_autoload_unregister(array($this, 'autoloader'));
    }
}

?>
